package com.dapeis.core.utils.json;

import java.lang.reflect.Type;

import com.ag.utils.json.AGsonBuilder;
import com.dapeis.core.utils.DBConfigUtils;
import com.dapeis.core.utils.RequirementConfig;
import com.dapeis.core.utils.StringUtil;
import com.dapeis.core.utils.UserInfoConfig;
import com.dapeis.domain.ext.UserInformationExt;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

/**
 * @author 作者 E-mail: hzyuanyong@126.com
 * @version 创建时间：2017年5月16日 上午8:59:16 类说明
 */
public class UserInformationExtGsonAdapter implements
	JsonSerializer<UserInformationExt> {

    @Override
    public JsonElement serialize(UserInformationExt src, Type typeOfSrc,
	    JsonSerializationContext context) {
	JsonObject  json  = new JsonObject();
	json.addProperty("sex", src.getSex());
	json.addProperty("faceshpe", DBConfigUtils.paserKey(src.getFaceshpe(), UserInfoConfig.getValue(src.getSex(), UserInfoConfig.FACESHPE)));
	json.addProperty("faceshpeImg","http://ryeyang.coding.me/Ms.DPS/prototype/customer/wechat/images/index/u1480.png");
	json.addProperty("colorofskin", DBConfigUtils.paserKey(src.getColorofskin(),UserInfoConfig.getValue(src.getSex(), UserInfoConfig.COLOROFSKIN)));
	json.addProperty("colorofskinImg", "http://ryeyang.coding.me/Ms.DPS/prototype/customer/wechat/images/index/u1691.png");
	json.addProperty("bodySize", DBConfigUtils.paserKey(src.getBodySize(), UserInfoConfig.getValue(src.getSex(), UserInfoConfig.SIZE)));
	json.addProperty("bodySizeImg","http://ryeyang.coding.me/Ms.DPS/prototype/customer/wechat/images/index/u1484.png");
	json.add(
		"problems",
		AGsonBuilder.create().toJsonTree(
			DBConfigUtils.paserUserInfoByDpsStrArray(src.getProblem(),UserInfoConfig.getValue(src.getSex(), UserInfoConfig.PROBLEM))));
	json.add(
		"styles",
		AGsonBuilder.create().toJsonTree(
			DBConfigUtils.paserUserInfoByDpsStrArray(src.getStyle(),UserInfoConfig.getValue(src.getSex(), UserInfoConfig.STYLE))));
	json.addProperty("weight", src.getWeight());
	json.addProperty("heigh", src.getHeigh());
	json.addProperty("chest", src.getChest());
	json.addProperty("waist", src.getWaist());
	json.addProperty("hip", src.getHip());
	json.addProperty("professional", StringUtil.isNotBlank(src
		.getProfessional()) ? src.getProfessional() : new String());
	json.addProperty("city", DBConfigUtils.getCity(src.getCityCode()));
	json.addProperty("birthday",
		DBConfigUtils.getAgeByBirthday(src.getBirthday()));
	json.add(
		"lifeImgs",
		AGsonBuilder.create()
			.toJsonTree(
				DBConfigUtils.paserRequirementLifeImg(src
					.getLifeImg())));
	return json;
    }

}
